package com.example.mqtt.conntroller;

import com.example.mqtt.common.response.Response;
import com.example.mqtt.entity.User;
import com.example.mqtt.service.UserService;
import jakarta.websocket.server.PathParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/5/17 10:50
 **/
@Slf4j
@RestController
@RequestMapping("/api/user")
@RequiredArgsConstructor
public class UserLoginController {
    private final UserService userService;

    @GetMapping("/login")
    public Response<String> userLogin(@PathParam("username") String username,
                                      @PathParam("password") String password) {
        return Response.success(userService.checkUserLogin(username, password));
    }

    @PostMapping("/register")
    public Response<String> registerUser(@RequestBody User user) {
        return Response.success(userService.registerUser(user));
    }
}
